<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY imt "http://xmlns.heustics.org/schema/imt/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   
  xmlns:str="http://exslt.org/strings"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:a="http://xmlns.heustics.org/schema/myelin/0.1/"
  xmlns:o="http://xmlns.heustics.org/schema/myelin/0.1/File#"  
  exclude-result-prefixes="xsl l a o str"
>  
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;File')"/> 
  <xsl:variable name="o:params-l10n" select="$o:l10n/l:context[@name='params']/*"/>
  <xsl:variable name="o:hints-l10n" select="$o:l10n/l:context[@name='param-hints']/*"/>
    
  <xsl:template match="a:source" mode="a:input-hidden"/>  
  
  <xsl:template match="a:source" mode="a:input-show">       
    <div class='input text source'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='source']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='source']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
      </div>      
      <div class='value'>
        <xsl:choose>
          <xsl:when test="@uri">
            <a href="{concat(a:format-node-action('download'),'&amp;modified=',@modified)}">
              <xsl:value-of select="$o:l10n/l:gentext[@key='download']"/>
            </a>   
          </xsl:when>
          <xsl:otherwise>
            <input class='file' type="file" name="source"/>
          </xsl:otherwise>
        </xsl:choose>       
        <div class="spacer"/>       
      </div>
      <div class='spacer'/>
    </div>     
  </xsl:template> 
  
  <xsl:template match="a:format" mode="a:input-show">      
    <div class='input text format'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='format']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='format']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
      </div>      
      <div class='value'>
        <xsl:choose>
          <xsl:when test="count(a:imts)">
            <xsl:apply-templates select="a:imts" mode="a:select">
              <xsl:with-param name="selected" select="@selected"/>
              <xsl:with-param name='imt-l10n' select="a:get-l10n('&imt;content-type')"/>
              <xsl:with-param name='name' select="'format'"/>
            </xsl:apply-templates>
          </xsl:when>
          <xsl:otherwise>
            <xsl:variable name="mime-toks" select="str:split(@selected,'/')"/>
            <span>
              <xsl:value-of select="a:get-l10n('&imt;content-type')/l:context[@name=$mime-toks[1]]/*[@key=$mime-toks[2]]"/>
            </span>
          </xsl:otherwise>          
        </xsl:choose>        
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>     
  
</xsl:stylesheet>

